package org.redmagic.service.controller.ui;

import java.util.List;

import org.redmagic.service.domain.ui.DisplayProperty;
import org.redmagic.service.ui.RedMagicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/read")
public class ReadPropertyController {

	@Autowired
	private RedMagicService redMagicService;
	
	@RequestMapping(value="/viewAll", method=RequestMethod.GET)
	public ModelAndView viewAll() {
		List<DisplayProperty> displayProperties = this.redMagicService.viewAllProperties();
		return new ModelAndView("viewAllProperties", "properties", displayProperties);
	}
	
	@RequestMapping(value="/", method=RequestMethod.GET)
	public String home() {
		return "redirect:/viewAll";
	}
}